Representation of Java data types in virtual machines

ABSTRACT

Improved techniques for representation of Java data types in virtual machines are disclosed. The techniques can be implemented to represent signatures of Java methods as arrays of references. Each of the references in an array can represent a parameter for a Java method. Accordingly, a signature can be represented as an array of references, wherein each reference in the array can reference a Java type indicator or an internal class representation. The Java type indicator represents a Java primitive type (e.g., byte, integer, double, etc.) The internal class representation is typically the representation of a Java class as represented in a virtual machine. As will be appreciated, an array organization allows for more efficient access to information. Thus, unlike conventional techniques, there is no need to start at the beginning of the signature and sequentially read it to find a particular parameter&#39;s data type. In addition, the internal class representations can be accessed directly from the method signature representation. This allows for quick access to the internal class representations from the signature, therefore, less processing is needed to execute methods. As a result, the performance of virtual machines, especially those operating with limited resources, can be improved.

BACKGROUND OF THE INVENTION

[0001] The present invention relates generally to object-based high level programming environments, and more particularly, to techniques for tracking references to objects defined in object-based high level programming environments.

[0002] One of the goals of high level languages is to provide a portable programming environment such that the computer programs may easily be ported to another computer platform. High level languages such as “C” provide a level of abstraction from the underlying computer architecture and their success is well evidenced from the fact that most computer applications are now written in a high level language.

[0003] Portability has been taken to new heights with the advent of the World Wide Web (“the Web”), which is an interface protocol for the Internet which allows communication of diverse computer platforms through a graphical interface. Computers communicating over the Web are able to download and execute small applications called applets. Given that applets may be executed on a diverse assortment of computer platforms, the applets are typically executed by a Java™ virtual machine.

[0004] Recently, the Java programming environment has become quite popular. The Java programming language is a language that is designed to be portable enough to be executed on a wide range of computers ranging from small devices (e.g., pagers, cell phones and smart cards) up to supercomputers. Computer programs written in the Java programming language (and other languages) may be compiled into Java Bytecode instructions that are suitable for execution by a Java virtual machine implementation. The Java virtual machine is commonly implemented in software by means of an interpreter for the Java virtual machine instruction set but, in general, may be software, hardware, or both. A particular Java virtual machine implementation and corresponding support libraries together constitute a Java runtime environment.

[0005] Computer programs in the Java programming language are arranged in one or more classes or interfaces (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operating system, independent. As such, these computer programs may be executed without modification on any computer that is able to run an implementation of the Java runtime environment.

[0006] Object-oriented classes written in the Java programming language are compiled to a particular binary format called the “class file format.” The class file includes various components associated with a single class. These components can be, for example, methods and/or interfaces associated with the class. In addition, the class file format can include a significant amount of ancillary information that is associated with the class. The class file format (as well as the general operation of the Java virtual machine) is described in some detail in The Java Virtual Machine Specification, Second Edition, by Tim Lindholm and Frank Yellin, which is hereby incorporated herein by reference.

[0007]FIG. 1A shows a progression of a simple piece of Java source code through execution by an interpreter, the Java virtual machine. Java source code 101 includes the classic Hello World program written in Java. The source code is then input into a Bytecode compiler 103 that compiles the source code into Bytecodes. The Bytecodes are virtual machine instructions as they will be executed by a software emulated computer. Typically, virtual machine instructions are generic (i.e., not designed for any specific microprocessor or computer architecture) but this is not required. The Bytecode compiler outputs a Java class file 105 that includes the Bytecodes for the Java program. The Java class file is input into a Java virtual machine 107. The Java virtual machine is an interpreter that decodes and executes the Bytecodes in the Java class file. The Java virtual machine is an interpreter, but is commonly referred to as a virtual machine as it emulates a microprocessor or computer architecture in software (e.g., the microprocessor or computer architecture may not exist in hardware).

[0008] Typically, the data types supported by the Java programming language are supported by Java virtual machine implementations. This means that both primitive and reference Java data types are supported by Java virtual machine implementations. The primitive Java data types are relatively simpler and include integral types (e.g., byte, short, int, long, char). As such, the values of the integral types of the Java virtual machines are the same as those for the integral types of the Java programming language. However, the reference data types have values that can be references to dynamically created class instances, or arrays (or class instances, or arrays that implement interfaces). It should also be noted that the reference data types are internally represented by the virtual machine.

[0009] In any case, the virtual machine needs to represent data types for various reasons, for example, to represent method signatures. A method signature describes the parameters and return type of a particular method. To illustrate, FIG. 1B depicts a method signature 120 in an internal method representation 122 which is generated by a virtual machine. The method signature 120 corresponds to a method “foo” 124. The method foo 124 has four parameters, namely, “byte”, “java.lang.string”, “double” and “java.util.date”. The signature 120 represents the data type of these four parameters. As such, the character “B” indicates that the first parameter is a “byte” type, “Ljava/lang/string” indicates that the second parameters is a “string” type, “D” indicates that the third parameter is a “double” type, and “Ljava/util/date” indicates that the fourth parameter is a “date” type. It should be noted that string and date represent reference data types. Accordingly, there may be a need to access the string and date classes in order to execute the method. In other words, there may be a need to locate the internal representation for classes associated with the reference data types (e.g., string and date data types). This means that to execute a method, the virtual machine has to do some processing to parse the signature and determine the data type for the parameters.

[0010] One problem with the conventional representation of Java data types is that the method signatures have to be read sequentially since data types can have various lengths. This means that the method signature has to be sequentially scanned from the beginning in order to access a particular parameters' data type. Furthermore, after the data type has been determined, there is a need to perform more processing to locate the class internal representation of the method's parameters (e.g., look it up in a table). The amount of processing required to sequentially read and then find the appropriate internal class representation can adversely affect the performance of virtual machines. This can seriously hinder the performance of virtual machines, especially those operating with relatively limited computing power (e.g., embedded systems).

[0011] In view of the foregoing, there is a need for improved techniques for representation of Java data types in virtual machines.

SUMMARY OF THE INVENTION

[0012] Broadly speaking, the present invention relates to representation of Java data types in virtual machines. Accordingly, the invention provides improved techniques for representation of Java data types in virtual machines. In accordance with one aspect of invention, signatures of Java methods can be represented in arrays of references. In one embodiment, each of the references in an array represents a parameter for a Java method. Accordingly, a signature can be represented as an array of references, wherein each reference in the array can reference a Java type indicator or an internal class representation. The Java type indicator represents a Java primitive type (e.g., byte, integer, double, etc.) The internal class representation is typically the representation of a Java class as represented in a virtual machine.

[0013] As will be appreciated, an array organization allows for more efficient access to information. Thus, unlike conventional techniques, there is no need to start at the beginning of the signature and sequentially read it to find a particular parameters' data type. In addition, the invention allows for the internal class representations to be directly accessed from the method signature representation. This allows for quick access to the internal class representations from the signature, and therefore, less processing is needed to execute methods. As a result, the invention can improve the performance of virtual machines, especially those operating with limited resources.

[0014] The invention can be implemented in numerous ways, including as a method, an apparatus, a computer readable medium, and a database system. Several embodiments of the invention are discussed below.

[0015] As a Java data type representation suitable for use by a Java virtual machine, one embodiment of the invention includes one or more data type indicators. Each one of the data type indicators represents a Java primitive type and an array of references. In addition, at least one reference in the array of references is referencing one of the one or more data type indicators.

[0016] As a Java method signature representation suitable for use in a Java virtual machine, one embodiment of the invention includes an array of references. Each reference in the array of references represents a parameter for a Java method such that an i^(th) entry of the array of references corresponds to an i^(th) parameter of the Java method, where i is a positive integer. Each one of references of the array of references reference a Java type indicator associated with a Java primitive type or an internal class representation associated with a Java class.

[0017] As a method of representing Java method signatures associated with Java methods with one or more parameters, one embodiment of the invention includes the acts of: determining whether a parameter has a primitive Java data type; assigning a reference in an array of references to a data type indicator that represents a Java primitive data type when the determining determines that the parameter has a primitive Java data type; and assigning a reference in an array of references to an internal class representation associated with a Java class when the determining determines that the parameter does not have a primitive data type.

[0018] As a computer readable media including computer program code for representing Java method signatures associated with Java methods with one or more parameters, one embodiment of the invention includes computer program code for determining whether a parameter has a primitive Java data type; computer program code for assigning a reference in an array of references to a data type indicator that represents a Java primitive data type when the determining determines that the parameter has a primitive Java data type; and computer program code for assigning a reference in an array of references to an internal class representation associated with a Java class when the the parameter does not have a primitive data type.

[0019] These and other aspects and advantages of the present invention will become more apparent when the detailed description below is read in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The present invention will be readily understood by the following detailed description in conjunction with the accompanying drawings, wherein like reference numerals designate like structural elements, and in which:

[0021]FIG. 1A shows a progression of a simple piece of Java source code through execution by an interpreter, the Java virtual machine.

[0022]FIG. 1B depicts a method signature in an internal method representation which is generated by a virtual machine.

[0023]FIG. 2A-B illustrate Java data type representation in accordance with one embodiment of the invention.

[0024]FIG. 2C depicts a representation of a method's signature in accordance with one embodiment of the invention.

[0025]FIG. 3 illustrates how a method signature may be represented in accordance with one embodiment of the invention.

[0026]FIG. 4 depicts several method signature representations in accordance with one embodiment of the invention.

[0027]FIG. 5 illustrates a method of representing a signature for a Java method with one or more parameters in accordance with one embodiment of the invention.

DETAILED DESCRIPTION OF THE INVENTION

[0028] The present invention pertains to improved techniques for representation of Java data types in virtual machines. In accordance with one aspect of invention, signatures of Java methods can be represented in arrays of references. In one embodiment, each of the references in an array represents a parameter for a Java method. Accordingly, a signature can be represented as an array of references, wherein each reference in the array can reference a Java type indicator or an internal class representation. The Java type indicator represents a Java primitive type (e.g., byte, integer, double, etc.) The internal class representation is typically the representation of a Java class as represented in a virtual machine.

[0029] As will be appreciated, an array organization allows for more efficient access to information. Thus, unlike conventional techniques, there is no need to start at the beginning of the signature and sequentially read it to find a particular parameters' data type. In addition, the invention allows for the internal class representations to be accessed directly from the method signature representation. This allows for quick access to the internal class representations from the signature, and therefore, less processing is needed to execute methods. As a result, the invention can improve the performance of virtual machines, especially those operating with limited resources (e.g., embedded systems).

[0030] Embodiments of the invention are discussed below with reference to FIGS. 2A-5. However, those skilled in the art will readily appreciate that the detailed description given herein with respect to these figures is for explanatory purposes only as the invention extends beyond these limited embodiments.

[0031]FIG. 2A illustrates a Java data type representation 200 in accordance with one embodiment of the invention. The Java data type representation 200 includes an array of references (e.g., pointers) 202 which include a series of references represented as entries 1 to M. Each of these entries can reference a data type indicator. For example, entry 1 of the array of references 202 can reference (e.g., point to) a data type indicator l. As will be appreciated, each of the primitive Java data types can be represented by the data type indicators 1 to N (i.e., be set to a particular value, for example, a string or an integer value to indicate a particular type). For example, data type indicators 1, 2, 3, and 4 can respectively represent the Java byte, integer, double, and character types. Thus, each of the entries of the array of references 202 can reference a primitive data type indicator.

[0032] As illustrated in FIG. 2B, an entry in an array of references 210 can also reference an internal class representation. This means that in addition to primitive Java data types, an array of references can also be used to represent reference Java data types. Accordingly, reference arrays can be used to, among other things, represent method's signatures. To illustrate, FIG. 2C depicts a representation of a method's signature 220 in accordance with one embodiment of the invention. The method's signature 220 represents a signature for a method with three parameters. Each of these parameters is represented by an entry in the array of references 222.

[0033] As shown, in FIG. 2C, entries 1, 2, and 3 of the array of references 222, respectively reference data type indicator 1, internal class representation 1, and data type indicator 3. In other words, parameters 1, 2, and 3 of the method represented by the method signature 220 respectively have data types represented by data type indicator 1, internal class representation 1, and data type indicator 3. As another example, FIG. 3 illustrates how the method signature 102 of FIG. 1 may be represented in accordance with one embodiment of the invention.

[0034] It should be noted that the internal class representations can be accessed directly from the method signature representation in accordance with one embodiment of the invention. This allows quick access to the internal class representations from the signature. As will be appreciated, less processing is needed to execute methods since internal representations can be accessed directly. As a result, the performance of virtual machines, especially those operating with limited resources can be improved.

[0035] Furthermore, the organization of method signature 220 allows for efficient access to various parameters of method signatures. By way of example, a particular parameter can be easily accessed by using the appropriate index (i.e., the third parameter is the 3^(rd) index, the fifth parameter is the 5^(th) index in the array, and so on). Thus, unlike conventional techniques, there is no need to start at the beginning of the signature and sequentially read it to find a particular parameter's data type.

[0036] As noted above, method signatures can be represented in an efficient manner in accordance with one aspect of the invention. It should also be noted that entries of different signature methods can reference the same data type indicator or internal class representation. In fact, there is a need to allocate one data type indicator for each Java data type. FIG. 4 depicts several method signature representations in accordance with one embodiment of the invention. Each of the method signature representations 402, 404, 406, 408 and 410 represent an array of references. As illustrated in FIG. 4, each of the internal class representations 1 and 2 can be referenced by two or more array reference entries. These array entries can be entries of the same array of references (e.g., method signature 410). Moreover, array entries in two different method signatures can reference the same data type indicator or internal class representation (e.g., entries in method signature representation 408 and 410 reference the internal class representation 2).

[0037]FIG. 5 illustrates a method 500 of representing a signature for a Java method with one or more parameters in accordance with one embodiment of the invention. The method 500 can be implemented, for example, in a Java virtual machine, to represent parameters of Java methods as an array of references. Each of the parameters of the Java method can be represented as a reference in the array of references. Initially, at operation 502, the first parameter of the Java method is identified. Next, at operation 504, a determination is made as to whether the parameter corresponds to a primitive Java data type (e.g., Byte, Integer, etc.) If it is determined at operation 504 that the parameter corresponds to a primitive Java data type, the method 500 proceeds to operation 506 where the reference representing the parameter in the array of references is set to the appropriate data type indicator. After the reference has been set to the appropriate data type indicator, the method 500 proceeds to operation 508 where it is determined whether there are more parameters to process. If it is determined at operation 508 that there are no more parameters to process, the method 500 ends. However, if it is determined at operation 508 that there is at least one parameter to process, the method 500 proceeds to operation 510 where the next parameter of the method is identified. Next, the method proceeds to operation 504 where a determination is made as to whether the parameter corresponds to a primitive Java data type. Thereafter, the method 500 proceeds in the same manner as discussed above.

[0038] However, if it is determined at operation 504 that the parameter does not correspond to a primitive Java data type (i.e., parameter corresponds to a reference object), the method 500 proceeds to operation 512 where the appropriate internal class representation for the parameter is identified. Next, the method 500 proceeds to operation 514 where the reference representing the parameter in the array of references is set to the internal class representation. After the reference has been set to the internal class representation, the method 500 proceeds to operation 508 where it is determined whether there are more parameters to process. Thereafter, the method 500 proceeds in the same manner as discussed above. When it is determined that the method does not have any more parameters to process, the method 500 ends.

[0039] The many features and advantages of the present invention are apparent from the written description, and thus, it is intended by the appended claims to cover all such features and advantages of the invention. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the invention to the exact construction and operation as illustrated and described. Hence, all suitable modifications and equivalents may be resorted to as falling within the scope of the invention. 

What is claimed is:
 1. In an object oriented computing environment, a Java data type representation suitable for use by a Java virtual machine, said Java data type representation comprising: one or more data type indicators, wherein each one of said data type indicators represents a Java primitive type; an array of references, wherein at least one reference in said array of references is referencing one of said one or more data type indicators.
 2. A Java data type representation as recited in claim 1, wherein at least one reference in said array of references is referencing an internal class representation associated with a Java class.
 3. A Java data type representation as recited in claim 3, wherein each one of the references in said array of references represent a parameter of a Java method.
 4. A Java data type representation as recited in claim 4, wherein two or more references in said array of references reference the same data type indicator.
 5. A Java data type representation as recited in claim 5, wherein two or more references in said array of references reference the same internal class representation associated with a Java class.
 6. A Java data type representation as recited in claim 1, wherein each one of references in said array of references represent a parameter of a Java method.
 7. A Java data type representation as recited in claim 1, wherein each reference in said array of references represents a parameter for a Java method such that the i^(th) entry of the array of references corresponds to the i^(th) parameter of said Java method, and wherein i is a positive integer.
 8. In an object oriented computing environment, a Java method signature representation suitable for use in a Java virtual machine, said Java method signature representation comprising an array of references: wherein each reference in said array of references represents a parameters for a Java method such that an i^(th) entry of the array of references corresponds to an i^(th) parameter of said Java method, and wherein i is a positive integer; and wherein each one of references of said array of references reference a Java type indicator associated with a Java primitive type or an internal class representation associated with a Java class.
 9. A Java method signature representation as recited in claim 9, wherein the data type for an i^(th) parameter of said Java method can be accessed without sequentially reading said array of references from its beginning.
 10. A Java method signature representation as recited in claim 9, wherein the internal class representation can be accessed by using a reference in said array of references without further processing.
 11. A Java method signature representation as recited in claim 8, wherein references in said array of references are direct references thereby allowing access to data types of said parameters without requiring further processing.
 12. A Java data type representation as recited in claim 8, wherein two or more references in said array of references reference the same data type indicator.
 13. A Java data type representation as recited in claim 8, wherein two or more references in said array of references reference the same internal class representation associated with a Java class.
 14. A method of representing Java method signatures associated with Java methods with one or more parameters, said method comprising: determining whether a parameter has a primitive Java data type; assigning a reference in an array of references to a data type indicator that represents a Java primitive data type when said determining determines that said parameter has a primitive Java data type; and assigning a reference in an array of references to an internal class representation associated with a Java class when said determining determines that said parameter does not have a primitive data type.
 15. A method as recited in claim 14, wherein said internal class representation can be accessed by using said reference in said array of references without further processing.
 16. A method as recited in claim 14, wherein references in said array of references are direct references thereby allowing access to data types of said parameters without requiring further processing.
 17. A method as recited in claim 14, wherein two or more references in said array of references reference the same data type indicator.
 18. A Java data type representation as recited in claim 8, wherein two or more references in said array of references reference the same internal class representation associated with a Java class.
 19. A computer readable media including computer program code for representing Java method signatures associated with Java methods with one or more parameters, said computer readable media comprising: computer program code for determining whether a parameter has a primitive Java data type; computer program code for assigning a reference in an array of references to a data type indicator that represents a Java primitive data type when said determining determines that said parameter has a primitive Java data type; and computer program code for assigning a reference in an array of references to an internal class representation associated with a Java class when said determining determines that said parameter does not have a primitive data type.
 20. A computer readable media as recited in claim 19, wherein said internal class representation can be accessed by using said reference in said array of references without further processing.
 21. A computer readable media as recited in claim 19, wherein references in said array of references are direct references thereby allowing access to data types of said parameters without requiring further processing.
 22. A computer readable media as recited in claim 19, wherein said Java method signatures are represented in a Java virtual machines. 